package cn.tedu.carehome.foundation.service.impl;

import cn.tedu.carehome.foundation.ex.ServiceException;
import cn.tedu.carehome.foundation.mapper.OlderStaffMapper;
import cn.tedu.carehome.foundation.mapper.CallMapper;
import cn.tedu.carehome.foundation.pojo.dto.CallAddNewDTO;
import cn.tedu.carehome.foundation.pojo.dto.CallLoginDTO;
import cn.tedu.carehome.foundation.pojo.entity.Call;
import cn.tedu.carehome.foundation.pojo.vo.CallListItemVO;
import cn.tedu.carehome.foundation.pojo.vo.CallStandardVO;
import cn.tedu.carehome.foundation.security.StaffDetails;
import cn.tedu.carehome.foundation.service.ICallService;
import cn.tedu.carehome.foundation.web.ServiceCode;
import com.alibaba.fastjson.JSON;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * 处理员工数据的业务实现类
 * @author 张子豪
 * @version 0.0.1
 */
@Service
@Slf4j
public class CallServiceImpl implements ICallService {
    @Autowired
    private CallMapper callMapper;

    public CallServiceImpl() {
        log.debug("创建业务对象：CallService");
    }

    //删除员工帐号的业务方法
    @Override
    public void deleteById(Long id) {
        log.debug("开始处理通过Id关闭报警信息");

        int row = callMapper.deleteById(id);
        if (row!=1){
            String message="关闭报警信息失败，服务器忙请稍后尝试";
            log.debug(message);
            throw  new ServiceException(ServiceCode.ERR_DELETE,message);
        }
    }

    //查询员工列表的业务
    @Override
    public List<CallListItemVO> list() {
        log.debug("开始执行查询报警信息的业务");
        //调用StaffMapper的list()方法查询员工列表
        List<CallListItemVO> list = callMapper.list();
        return list;
    }

}
